package com.sheng.service.impl;

import com.sheng.dao.BookDao;
import com.sheng.pojo.Book;
import com.sheng.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class BookServiceImpl implements BookService {

    @Autowired
    private BookDao bookDao;

    @Override
    public List<Book> getAllBooks() {
        return (List<Book>) bookDao.findAll();
    }

    @Override
    public Long addBook(Book book) {
        Book saveBook = bookDao.save(book);
        return saveBook.getId();
    }

    @Override
    public void deleteBook(Long id) {
        bookDao.deleteById(id);
    }
}
